--TEST--
int MySQLndUhConnection::getWarningCount(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function getWarningCount($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::getWarningCount($res));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function getWarningCount($res) {
			return 12;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function getWarningCount($res) {
			$ret = new stdClass();
			return $ret;
		}
	}

	class proxy4 extends MySQLndUhConnection {
		public function getWarningCount($res) {}
	}

	class proxy5 extends MySQLndUhConnection {
		public function getWarningCount($res) {
			return PHP_INT_MAX;
		}
	}

	function test_warning_count($conn, $offset, $warning_count) {

		if (!$conn->query("INSERT INTO test(col1) VALUES (1000000)")) {
			printf("[%03d + 1] [%d] '%s'\n", $offset, $conn->errno, $conn->error);
			return false;
		}
		if ($warning_count != $conn->warning_count) {
			printf("[%03d + 2] Expecting %d got %s\n", $offset, $warning_count, $conn->warning_count);
			return false;
		}
		return false;
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);
	if (!$conn->query("DROP TABLE IF EXISTS test")
		|| !$conn->query("CREATE TABLE test(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, col1 SMALLINT)"))
		printf("[001] [%d] '%s'\n", $conn->errno, $conn->error);

	test_warning_count($conn, 2, 1);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	test_warning_count($conn, 3, 1);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	test_warning_count($conn, 4, 12);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	test_warning_count($conn, 5, 3);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	test_warning_count($conn, 6, 0);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy5());
	test_warning_count($conn, 7, PHP_INT_MAX);
	mysqlnd_uh_test\query_test::mysqli($conn);

	print "done!";
?>
--EXPECTF--
proxy::getWarningCount(array (
  0 => NULL,
))
int(1)

Warning: test_warning_count(): (MySQLnd User Handler) The method MySQLndUhConnection::getWarningCount() did not return a numeric value as it should (C type used by mysqlnd: "unsigned int") in %s on line %d

Warning: test_warning_count(): (MySQLnd User Handler) The method MySQLndUhConnection::getWarningCount() did not return a numeric value as it should (C type used by mysqlnd: "unsigned int") in %s on line %d
done!